package com.eliza.springboot.v3.config.properties

import org.springframework.boot.SpringBootConfiguration
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean


// 方案二

data class CustomConfig(var port: Int = 0, var name: String)

/*
* EnableConfigurationProperties 快速注解/导入第三方包
* sheep组件的属性绑定
* 默认会把组件放在容器中（@Bean
* */
@EnableConfigurationProperties(CustomSheepConfig::class)
@SpringBootConfiguration
class CustomConfiguration {


    //   方法绑定
    @Bean
    @ConfigurationProperties(prefix = "v3.config.method")
    fun greeting(): CustomConfig {
        return CustomConfig(0, "1")
    }

}


